
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
  <title>个人资料</title>
  <link rel="stylesheet" href="__PUBLIC__/mobile/css/public.css">
  <link rel="stylesheet" href="__PUBLIC__/mobile/css/login.css">

  <link href="__PUBLIC__/css/layui.css" rel="stylesheet" type="text/css" media="all"/>
  <script type="text/javascript" src="__PUBLIC__/layui.js"></script>

  <script src="__PUBLIC__/mobile/js/jquery-1.8.3.min.js" type="text/javascript"></script>
  <script src="__PUBLIC__/mobile/js/wxd.js" type="text/javascript"></script>

    <style type="text/css">
    .sendcode{
position: absolute;
    width: 100px !important;
    right: 0;
    top: 0;
    text-align: center;
    padding: 0 !important;
    background-color: #094;
    color: #fff;
    border-radius: 5px !important;
    cursor:pointer;
    }
  </style>
</head>
<body>
  <header class="nav">
      <a class="nav-return" href="{:U('mobile/info/what_laoshi',array('newcity'=>$city))}"></a>
      <h1 class="nav-title">授课信息</h1>
      <span class="nav-right">
          <a class="nav-btn-reg" href="{:U('mobile/info/what_laoshi',array('newcity'=>$city))}">返回</a>
      </span>
  </header>
  
  <section class="main">
      <div class="logo">
          <img width="230" height="64" class="logo" src="__PUBLIC__/mobile/images/logo.png">
      </div>
      <form class="form layui-form" method="post">
          <div class="input-wrap">所在区域：
              <select name="sk_city" id="" lay-verify="sk_city">
                      <!-- <option value="{$showke_info.sk_city}">{$showke_info.sk_city}</option> -->
                  <?php foreach ($city_quyu as $c) { ?>
                      <option value="{$c.city_name}" {$c['city_name'] == $showke_info['sk_city']?"selected":''}>{$c.city_name}</option>
                  <?php } ?>
              </select>
              <i class="i-close"></i>
          </div>
          <div class="input-wrap">授课科目：
              <select name="subject" id="" lay-verify="subject">
                  <?php foreach ($subjects as $c) { ?>
                      <option value="{$c.grade_name}" {$c['grade_name'] == $showke_info['subject']?"selected":''}>{$c.grade_name}</option>
                  <?php } ?>
              </select>
              <i class="i-close"></i>
          </div>
          <div class="input-wrap">
              <span style=" position: absolute;padding-top: 7px;">授课范围：</span>
              <input type="text" name="address" lay-verify="address" value="{$showke_info.address}" placeholder="请输入授课区域 地铁或区域" style="padding-left: 80px;">
              <i class="i-close"></i>
          </div>
          <div class="input-wrap">
              <span style=" position: absolute;padding-top: 7px;">最低收费：</span>
              <input type="text" lay-verify="price" name="price" value="{$showke_info.price}" placeholder="请输入课时费 (元/时) 起" style="padding-left: 80px;">
              <i class="i-close"></i>
          </div>
          <div class="input-wrap">授课方式：
              <?php foreach ($methods as $m) { ?>
                  <input class="methods" name="methods" lay-verify="methods" type="checkbox" value="{$m['id']}"<?php if (in_array($m['id'], $showke_methods)) { ?>
                checked <?php } ?>>{$m.method_name}
              <?php } ?> 
              <i class="i-close"></i>
          </div>
          <div class="input-wrap">
              <table style="clear:both; width:100%;" class="tbhju">
                  <colgroup>
                      <col width="16%">
                      <col width="12%">
                      <col width="12%">
                      <col width="12%">
                      <col width="12%">
                      <col width="12%">
                      <col width="12%">
                      <col width="12%">
                  </colgroup>
                  <thead>
                      <tr id="uinp">
                          <th>&nbsp;</th>
                          <th>周一</th>
                          <th>周二</th>
                          <th>周三</th>
                          <th>周四</th>
                          <th>周五</th>
                          <th>周六</th>
                          <th>周日</th>
                      </tr>
                  </thead>
                  <tbody id="uMw">
                      <tr>
                          <td class="timE">上午</td>
                          <?php  foreach ($showke_time_sw as $t) { ?>
                          <td class="sL"><input class="showke_time" type="checkbox" name="sm_shijian" value="{$t.id}"<?php if (in_array($t['id'], $shouke_times)) { ?>
                            checked
                          <?php } ?> /></td>
                          <?php } ?>
                      </tr>
                      <tr>
                          <td class="timE">下午</td>
                          <?php  foreach ($showke_time_xw as $t) { ?>
                          <td class="sL"><input class="showke_time" type="checkbox" name="sm_shijian" value="{$t.id}"<?php if (in_array($t['id'], $shouke_times)) { ?>
                            checked
                          <?php } ?> /></td>
                          <?php } ?>
                      </tr>
                      <tr>
                          <td class="timE">晚上</td>
                          <?php  foreach ($showke_time_ws as $t) { ?>
                          <td class="sL"><input class="showke_time" type="checkbox" name="sm_shijian" value="{$t.id}"<?php if (in_array($t['id'], $shouke_times)) { ?>
                            checked
                          <?php } ?> /></td>
                          <?php } ?>
                      </tr>
                  </tbody>
              </table>
            <i class="i-close"></i>
          </div>
          <input type="hidden" name="id" value="{$id}">
          <input type="hidden" name="newcity" value="{$city}">
          <input type="hidden" name="wh" value="{$wh}">
          <input type="hidden" name="grade" value="{$grade}">
          <button class="btn-submit" style="margin-top: 20px;" lay-submit lay-filter="*">提&nbsp;&nbsp;交</button>
      </form>
  </section>
<script type="text/javascript">
    layui.use(['form','layer'], function(){
      var layer = layui.layer
      ,form = layui.form();
      //layer.msg('Hello World');

    //自定义验证规则
    form.verify({
      sk_city: function(value){
        if(value.length < 1){
          return '所在区域不能为空';
        }
      }
      ,subject: function(value){
        if(value.length < 1){
          return '科目不能为空';
        }
      }
      ,address: function(value){
        if(value.length < 1){
          return '授课范围不能为空';
        }
      }
      ,price: function(value){
        if(value.length < 1){
          return '最低收费不能为空';
        }
      }
    });

    form.on('submit(*)', function(data){
        //上门方式
        var methods = new Array();
        var chenked=$(".methods:checked").each(function(){
           methods.push($(this).val()); 
        })
        data.field.methods = methods;

        //授课时间
        var sm_shijian = new Array();
        var chenked=$(".showke_time:checked").each(function(){
           sm_shijian.push($(this).val()); 
        })
        data.field.sm_shijian = sm_shijian;
      //console.log(data);
    $.ajax({
        url: "{:U('mobile/info/ls_showke_add')}",//请求地址
        type: "post",//请求方式
        dataType: "json",//返回数据类型
        data: data.field,//发送的参数
        })
        .done(function(response) {
              if(response.error==0){
                 layer.msg(response.info ,{icon:5});

              }else{
                 layer.msg(response.info ,{icon:6});
                 location.href = response.url;

              }
          })
        .fail(function() {
            alert("ajxs交互失败");
        })  

      return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
    });   
    });
</script>
</body>
</html>

